#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<assert.h>
//
//int main() {
//	int a[10] = { 1,2,3,4,5,1,2,3,4,6 };
//	int b[1000] = { 0 };
//	int n1 = 0;
//	int n2 = 0;
//	for (int i = 0; i < 10; i++) {
//		b[a[i]]++;
//	}
//	for (int i = 0; i < 1000; i++) {
//		if (b[i]== 1) {
//			printf("%d ",i);
//		}
//	}
//	return 0;
//}

char* my_strncpy(char* dest, char* src, int n) {
	char* res = dest;
	assert(dest && src);
	int len1 = strlen(dest);
	int len2 = strlen(src);
	//printf("%d %d", len1, len2);
	if (n <=len1 && n <= len2) {
		while (n) {
			*dest = *src;
			dest++;
			src++;
			n--;
		}
	}
	return res;
}
char* my_strncat(char* dest, char* src, int n) {
	assert(dest && src);
	int len2 = strlen(src);
	char* res = dest;
	int len1 = strlen(dest);
	dest = dest + len1;
	if (n <= len2) {
		while (n) {
			*dest = *src;
			dest++;
			src++;
			n--;
		}
		*dest = '\0';
	}
	return res;
}

int my_atoi(char* num1) {
	assert(num1);
	int len = strlen(num1);
	int ans = 0;
	for (int i = 0; i < len; i++) {
		if (num1[i] >= '0' && num1[i] <= '9') {
			ans = ans * 10 + num1[i] - '0';
		}
		else {
			return -1;
		}
	}
	return ans;
}
int main() {
	char arr1[30] = "dasdghh";
	char arr2[30] = "annnnna";
	char* a1 = arr1;
	char* a2 = arr2;
	//char* arr3=my_strncpy(arr1, arr2, 3);
	char* arr3 = my_strncat(a1, a2, 3);
	printf("%s",arr3);

	//printf("%d", my_atoi("1234"));

	return 0;
}